package com.education.wisdom.controller;


import com.education.common.utils.ApiReturnObject;
import com.education.wisdom.feign.WelcoFeign;
import com.education.wisdom.pojo.Banner;
import com.education.wisdom.service.IBannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("web/banner")
public class FullBannerController {

    @Autowired
    private IBannerService iBannerService;

    @Autowired
    private WelcoFeign welcoFeign;

    @GetMapping("/list")
    public ApiReturnObject list() {
        List<Banner> list = iBannerService.selectBannerList();
        return new ApiReturnObject("200", "success", list);
    }

    /**
     * 判断welco服务是否启动
     * @return
     */
    @GetMapping("/isWelco")
    public ApiReturnObject isWelco() {
        String s = null;
        try {
            s = welcoFeign.isWelco();
            return new ApiReturnObject("200", "success", "1");
        } catch (Exception e) {
            return new ApiReturnObject("201", "failure", "0");
        }
    }
}
